<template>
  <div
    id="box"
    :class="{ success: flag == 1, error: flag == 2, default: flag == 0 }"
  >
    <input
      :placeholder="placeholder"
      :value="value"
      @input="changeInput"
      :type="type"
    />
    <slot name="icon"></slot>
  </div>
</template>

<script>
export default {
  props: {
    placeholder: {
      type: String,
      default: "请输入内容",
    },
    value: {
      type: String,
    },
    flag: {
      type: Number,
      default: 0,
    },
    type: {
      type: String,
    },
  },
  data() {
    return {};
  },
  mounted() {},
  methods: {
    changeInput(e) {
      this.$emit("input");
      this.$emit("input", e.target.value);
    },
  },
  components: {},
};
</script>

<style lang="scss" scoped>
#box {
  width: 100%;
  height: 3rem;
  border-radius: 5px;
  display: flex;
  align-items: center;
  background-color: rgb(236, 233, 233);
  justify-content: space-between;
  padding: 0 10px;
  margin: 0.8125rem 0;
  input {
    outline: none;
    border: 0;
    background-color: transparent;
    height: 100%;
  }
}

.success {
  background-color: rgb(120, 224, 111) !important;
}
.error {
  background-color: rgb(221, 104, 104) !important;
}
</style>
